import numpy as np
import sys
with open(sys.argv[1], 'r') as ipt:
    res = ipt.readlines()
Nindex = [0]
N = 0
while (N+6)<len(res):
    if res[N+5].strip().isdigit():
        N += 5
        Nindex.append(N)
    elif res[N+6].strip().isdigit():
        N += 6
        Nindex.append(N)
    else:
        break
N = len(Nindex)
Nindex.append(len(res))
print(N, Nindex)
with open(sys.argv[2], 'w') as opt, open(sys.argv[3], 'w') as opt2, open(sys.argv[4],'w') as f:
    for i in range(N):
        r = res[Nindex[i]+2].split('/')
        if len(r[0].split(' '))>1:
            f.write(''.join(r[0].split(' ')) + ' ' + res[Nindex[i] + 4])
        else:
            opt.write(r[0] + ' ' + res[Nindex[i]+4])
            if Nindex[i+1]-Nindex[i]<6:
                upper = ''
            else:
                upper = res[Nindex[i]+5]
                opt2.write(r[0] + ' ' + upper)
